package main

import (
	"io"
	"net/http"

	"github.com/astaxie/beego"
	"github.com/beego/i18n"
	"go.web.demo/controllers"
)

func sayHello(rw http.ResponseWriter, req *http.Request) {
	io.WriteString(rw, "Hello world, this is version 1.")
}

func main() {
	// //设置路由
	// http.HandleFunc("/", sayHello)
	// err := http.ListenAndServe(":8080", nil)
	// if err != nil {
	// 	log.Fatal(err)
	// }

	//i18n 多语言国际化
	beego.Router("/i18n", &controllers.I18nController{})
	i18n.SetMessage("zh-CN", "conf/locale_zh-CN.ini")
	i18n.SetMessage("en-US", "conf/locale_en-US.ini")
	//注册模板函数
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
